import cv2
import numpy as np
import sys

img = cv2.imread(r'./02.png')
img1 = img.copy()

if img is None:
    print('Falied to read the lena.jpg')
    sys.exit()

cv2.namedWindow('Brighter', cv2.WINDOW_NORMAL)
value = 80


def call_back_brightness(param):
    global value, img, img1
    # 获取轨迹栏上的数值
    value = cv2.getTrackbarPos('brightness', 'Brighter')
    img1 = np.uint8(np.clip((value/100*img), 60, 255))


# 创建划动的进度条，进度条的回调
cv2.createTrackbar('brightness', 'Brighter', value, 255, call_back_brightness)

while True:
    cv2.imshow('Brighter', img1)
    if cv2.waitKey(2) == 27:
        break
cv2.destroyAllWindows()


